package com.westos.todo.entity;

import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.FactoryBean;

import com.westos.todo.dao.TodoDAO;

public class TodoDAOFactoryBean implements FactoryBean<TodoDAO>{
	
	private SqlSessionFactory sqlSessionFactory;

	@Override
	public TodoDAO getObject() throws Exception {
		
		return sqlSessionFactory.openSession().getMapper(TodoDAO.class);
	}

	@Override
	public Class<?> getObjectType() {
		
		return TodoDAO.class;
	}

	@Override
	public boolean isSingleton() {
		
		return true;
	}

	public SqlSessionFactory getSqlSessionFactory() {
		return sqlSessionFactory;
	}

	public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
		this.sqlSessionFactory = sqlSessionFactory;
	}
	

}
